﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Lib.Utility;
using Module.BusinessLogic;

namespace Web.UserControls
{
    public partial class cauthu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                GetData();
            }
            catch (Exception)
            {
                             
            }
        }

        void GetData()
        {
            int totalRecords;
            int cPage = 1;
            if (Request.QueryString.Get("cpage") != null)
                cPage = ConvertUtility.ToInt32(Request.QueryString.Get("cPage"));
            int from = (cPage - 1) * 4 + 1;
            if (from == 0) from = 1;
            int to = (cPage) * 4;
            totalRecords = CMSFootballPlayer.GetCount();
            DataTable dt;
            string order = null;
            dt = CMSFootballPlayer.Getlist(from, to, order);
            ltData.Text = "";
            int i = 0;
            if (dt != null && dt.Rows.Count > 0)
            {
                int totalPages = (int)Math.Ceiling((double)totalRecords / 4);
                if (cPage < totalPages)
                {                    
                    lnkNext.Attributes.Add("onclick", "ListCauthu('" + Convert.ToInt32(cPage + 1) + "')");
                }
                if (cPage > 1)
                {                    
                    lnkPrev.Attributes.Add("onclick", "ListCauthu('" + Convert.ToInt32(cPage - 1) + "')");
                }

                foreach (DataRow dr in dt.Rows)
                {
                    i++;
                    if (i == 1)
                    {
                        ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/cauthuchitiet.aspx?id=" + dr["FootBallId"] + "','Chi tiet',648,500,null,null)\"><img width=\"160px\" heght=\"160px\" title=\"" + dr["fullName"] + "\" src=\"" + dr["Avatar"].ToString() + "\" style=\"margin-top:10px;border:0px; margin-left:20px;\"/></a></div>";
                    }
                    if (i == 2)
                    {
                        ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/cauthuchitiet.aspx?id=" + dr["FootBallId"] + "','Chi tiet',648,500,null,null)\"><img width=\"160px\" heght=\"160px\" title=\"" + dr["fullName"] + "\" src=\"" + dr["Avatar"].ToString() + "\" style=\"border:0px; margin-left:20px;\"/></a></div>";
                    }
                    if (i == 3)
                    {
                        ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/cauthuchitiet.aspx?id=" + dr["FootBallId"] + "','Chi tiet',648,500,null,null)\"><img width=\"160px\" heght=\"160px\" title=\"" + dr["fullName"] + "\" src=\"" + dr["Avatar"].ToString() + "\" style=\"margin-top:100px; border:0px; margin-left:20px;\"/></a></div>";
                    }
                    if (i == 4)
                    {
                        ltData.Text += "<div class=\"fr\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/cauthuchitiet.aspx?id=" + dr["FootBallId"] + "','Chi tiet',648,500,null,null)\"><img width=\"160px\" heght=\"160px\" title=\"" + dr["fullName"] + "\" src=\"" + dr["Avatar"].ToString() + "\" style=\"margin-top:20px; border:0px; margin-right:100px;\"/></a></div>";
                    }
                    //if (i == 5)
                    //{
                    //    ltData.Text += "<div class=\"fr\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/cauthuchitiet.aspx?id=" + dr["FootBallId"] + "','Chi tiet',648,500,null,null)\"><img title=\"" + dr["fullName"] + "\" src=\"" + dr["Avatar"].ToString() + "\" style=\"margin-top:20px; border:0px;margin-right:30px;\"/></a></div>";
                    //}
                }
            }
        }
    }
}